package com.vortex.cloud.zhsw.xinyang.converter;

import com.github.liaochong.myexcel.core.container.Pair;
import com.github.liaochong.myexcel.core.converter.ConvertContext;
import com.github.liaochong.myexcel.core.converter.WriteConverter;
import com.vortex.cloud.vfs.lite.base.dto.GeometryDTO;

import java.lang.reflect.Field;

/**
 * 经纬度字段导出转换
 *
 * @author huohao@vortexinfo.cn
 * @date 2022/3/18 8:59
 */
public class GeometryWriteConverter implements WriteConverter {
    @Override
    public Pair<Class, Object> convert(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
        GeometryDTO geometryDTO = (GeometryDTO) fieldVal;
        return Pair.of(String.class, geometryDTO.getLngLats());
    }

    @Override
    public boolean support(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
        return fieldType == GeometryDTO.class;
    }
}
